#!/usr/bin/python

import pdb
'''
from random import randint
import sys

from time import time, localtime, strftime

count = 0
number = [1, 2, 3, 4]
for i in number:
    for j in number:
        j *= 10
        for k in number:
            k *= 100
            print(i + j + k, end=' ')
            count += 1

print(f"\ntotal: {count}\n")


if(len(sys.argv) > 1):
    profit = int(sys.argv[1])
else:
    profit = randint(1, 1000)

print(f"Your contribute to the company: {profit}0,000")


reward = 0
if profit <= 10:
    reward = profit * 0.1
elif profit <= 20:
    reward = 1 + (profit - 10)*0.075
elif profit <= 40:
    reward = 1.75 + (profit - 20) * 0.05
elif profit <= 60:
    reward = 2.75 + (profit - 40) * 0.03
elif profit <= 100:
    reward = 3.35 + (profit - 60) * 0.015
elif profit > 100:
    reward = 3.95 + (profit - 100) * 0.01

ugly = reward
print(f"ugly: {reward}")

segment = [100, 60, 40, 20, 10, 0]
ratio = [0.01, 0.015, 0.03, 0.05, 0.075, 0.1]

reward = 0
for i in range(0, len(segment)):
    j = segment[i]
    if(profit > j):
        reward += (profit - j)*ratio[i]
        profit = j

print(f"Your can get: {reward}")

# assert(ugly == reward), "See you in the court!"

for i in range(2, 86, 2):
    if 168 % i != 0:
        continue
    j = 168/i
    if i > j:
        break
    k = i-j
    if k % 2 != 0:
        continue
    n = k/2
    k = i + j
    if k % 2 != 0:
        continue
    m = k/2
    print(n*n - 100, end=' ')


# leap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
nonleap = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

year = randint(1, 3000)
month = randint(1, 12)
date = randint(1, 28)

print(f"\n{year}-{month}-{date}")

days = 0
for i in range(1, month):
    days += nonleap[i]

days += date

if month > 2:
    if year % 4 == 0:
        days += 1


print(f"day of the year: {days}")

unordered = []
len = randint(8, 16)
for i in range(1, len):
    unordered.append(randint(1, 1024))

print(f"\n unordered: {unordered}")

print(f"sorted:{sorted(unordered)}\n")


a, b = 0, 1

while b < randint(1, 1024):
    print(a, end=' ')
    a, b = b, a+b

print("\n")

for i in range(1, 10):
    for j in range(i, 10):
        print("%d*%d=%d" % (i, j, i*j), end=' ')
    print("\n")


print("%s\n" % strftime("%Y-%m-%d %H:%M:%S", localtime(time())))

month = randint(1, 12)
grown = 0
adolescent = 0
# nursling = 2
born = 1

for i in range(1, month):
    grown += adolescent
    adolescent = born
    born = grown
    print("Month %d: %d" % (i+1, born+adolescent+grown))

print("\n")

x = randint(1, 10)
n = randint(1, 10)
x = 4
n = 5

print(f"x={x}, n={n}")

sum = 0

for i in range(1, n):
    b = 0
    for k in range(0, i):
        b += (x * (10 ** k))
    sum += b

print(f"total: {sum}")


heighest = height = 100
n = 10
sum = 0

print(f"heighest: {heighest}")

for i in range(1, 11):
    sum += height * 2
    height /= 2

sum -= heighest

print(f"after {n} times bound: {sum}")

last = 1

for i in range(1, 10):
    last = (last+1)*2

print(last)


def satisfy(x):
    if x < 10 or x > 99:
        return 0
    tmp = 809 * x
    if tmp < 1000 or tmp > 9999:
        return 0
    tmp = 8 * x
    if tmp < 10 or tmp > 99:
        return 0
    tmp = 9 * x
    if tmp < 100 or tmp > 999:
        return 0
    return 1


for i in range(10, 100):
    if satisfy(i):
        print("x = %d, 809 * x = %d" % (i, 809 * i))
        print("x * 8 = %d" % (8 * i))
        print("x * 9 = %d" % (9 * i))

'''
n = 5


def satisfy(x):
    if isinstance(x, str):
        if not x.isdigit():
            return 0
        try:
            x = float(x)
        except ValueError:
            return False

    if isinstance(x, float):
        if not x.is_integer():
            return 0

        '''
    for i in range(1, n):
        if (x - 1) % n != 0:
            return False
        x = (x - 1)/n * 4

    return True
        '''
    for i in range(1, n + 1):
        if x % 4 != 0:
            return False
        x = x / 4 * 5 + 1
    print("Total: %d" % x)
    return True


# pdb.set_trace()
for i in range(1020, 10000):
    if satisfy(i):
        print(i)
        break
